package avicit.bdp.dcs.semistructure.dto;

import avicit.bdp.common.base.BaseDTO;
import avicit.platform6.core.annotation.log.FieldRemark;
import avicit.platform6.core.annotation.log.Id;
import avicit.platform6.core.annotation.log.LogField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.multipart.MultipartFile;

import javax.persistence.Column;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.Max;
import javax.validation.constraints.Pattern;

/**
 * 模板实体类(bdp_dcs_template)
 */
@ApiModel(value = "TemplateDTO", description = "bdp_dcs_template")
@Table(name = "bdp_dcs_template")
public class TemplateDTO extends BaseDTO {

    private static final long serialVersionUID = 1L;

    // 主键
    @Id
    @LogField
    @ApiModelProperty(value = "主键")
    @FieldRemark(column = "id", field = "id", name = "id")
    @javax.persistence.Id
    @Column(name = "id")
    private String id;

    // 模板名称
    @LogField
    @ApiModelProperty(value = "模板名称")
    @FieldRemark(column = "template_name", field = "templateName", name = "模板名称")
    @Column(name = "template_name")
    private String templateName;

    // 存储目录
    @LogField
    @ApiModelProperty(value = "存储目录")
    @FieldRemark(column = "store_catalog", field = "storeCatalog", name = "存储目录")
    @Column(name = "store_catalog")
    private String storeCatalog;

    // 上传文件名称长度限制
    @LogField
    @ApiModelProperty(value = "上传文件名称长度限制")
    @FieldRemark(column = "length_limit", field = "lengthLimit", name = "上传文件名称长度限制")
    @Column(name = "length_limit")
    @Max(value = 30, message = "上传文件名称长度限制30个字符,请输入正确数值！")
    private Integer lengthLimit;

    // 上传文件大小限制(MB)
    @LogField
    @ApiModelProperty(value = "上传文件大小限制(MB)")
    @FieldRemark(column = "file_size_limit", field = "fileSizeLimit", name = "上传文件大小限制(MB)")
    @Column(name = "file_size_limit")
    @Max(value = 204800, message = "上传文件大小限制204800M,请输入正确数值！")
    private Integer fileSizeLimit;

    // 启用名称格式限制，是：1，否：0
    @LogField
    @ApiModelProperty(value = "启用名称格式限制，是：1，否：0")
    @FieldRemark(column = "enable_format_limit", field = "enableFormatLimit", name = "启用名称格式限制，是：1，否：0")
    @Column(name = "enable_format_limit")
    private Integer enableFormatLimit;

    // 描述
    @LogField
    @ApiModelProperty(value = "描述")
    @FieldRemark(column = "remark", field = "remark", name = "描述")
    @Column(name = "remark")
    private String remark;

    // 列规则[{"name":"id","type":"String"}]
    @LogField
    @ApiModelProperty(value = "列规则[{\"name\":\"id\",\"type\":\"String\"}]")
    @FieldRemark(column = "column_rule", field = "columnRule", name = "列规则")
    @Column(name = "column_rule")
    private String columnRule;

    // 文件类型
    @LogField
    @ApiModelProperty(value = "文件类型")
    @FieldRemark(column = "file_type", field = "fileType", name = "文件类型")
    @Column(name = "file_type")
    private Integer fileType;

    // 分隔符
    @LogField
    @ApiModelProperty(value = "分隔符")
    @FieldRemark(column = "file_separator", field = "fileSeparator", name = "分隔符")
    @Column(name = "file_separator")
    @Pattern(regexp = "^[, |_-]${1}", message = "分隔符长度限制一个字符，可以为英文逗号，竖线|，下划线_,横杠-，空格")
    private String fileSeparator;

    // md5
    @LogField
    @ApiModelProperty(value = "md5")
    @FieldRemark(column = "md5", field = "md5", name = "md5")
    @Column(name = "md5")
    private String md5;

    // 组织机构代码
    @ApiModelProperty(value = "组织机构代码")
    @FieldRemark(column = "org_identity", field = "orgIdentity", name = "组织机构代码")
    @Column(name = "org_identity")
    private String orgIdentity;

    // 密级
    @ApiModelProperty(value = "密级")
    @FieldRemark(column = "secret_level", field = "secretLevel", name = "密级")
    @Column(name = "secret_level")
    private String secretLevel;

    @ApiModelProperty(value = "文件对象")
    @Transient
    private MultipartFile file;

    @ApiModelProperty(value = "文件路径")
    @Transient
    private String filePath;

    @ApiModelProperty(value = "是否关联文件")
    @Transient
    private boolean isRelatedFile;

    public MultipartFile getFile() {
        return file;
    }

    public boolean isRelatedFile() {
        return isRelatedFile;
    }

    public void setRelatedFile(boolean relatedFile) {
        isRelatedFile = relatedFile;
    }

    public void setFile(MultipartFile file) {
        this.file = file;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getTemplateName() {
        return templateName;
    }

    public void setTemplateName(String templateName) {
        this.templateName = templateName;
    }

    public String getFileSeparator() {
        return fileSeparator;
    }

    public void setFileSeparator(String fileSeparator) {
        this.fileSeparator = fileSeparator;
    }

    public String getStoreCatalog() {
        return storeCatalog;
    }

    public void setStoreCatalog(String storeCatalog) {
        this.storeCatalog = storeCatalog;
    }

    public Integer getLengthLimit() {
        return lengthLimit;
    }

    public void setLengthLimit(Integer lengthLimit) {
        this.lengthLimit = lengthLimit;
    }

    public Integer getFileSizeLimit() {
        return fileSizeLimit;
    }

    public void setFileSizeLimit(Integer fileSizeLimit) {
        this.fileSizeLimit = fileSizeLimit;
    }

    public Integer getEnableFormatLimit() {
        return enableFormatLimit;
    }

    public void setEnableFormatLimit(Integer enableFormatLimit) {
        this.enableFormatLimit = enableFormatLimit;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getColumnRule() {
        return columnRule;
    }

    public void setColumnRule(String columnRule) {
        this.columnRule = columnRule;
    }

    public Integer getFileType() {
        return fileType;
    }

    public void setFileType(Integer fileType) {
        this.fileType = fileType;
    }

    @Override
    public String getOrgIdentity() {
        return orgIdentity;
    }

    @Override
    public void setOrgIdentity(String orgIdentity) {
        this.orgIdentity = orgIdentity;
    }

    @Override
    public String getSecretLevel() {
        return secretLevel;
    }

    @Override
    public void setSecretLevel(String secretLevel) {
        this.secretLevel = secretLevel;
    }

    public String getFilePath() {
        return filePath;
    }

    public void setFilePath(String filePath) {
        this.filePath = filePath;
    }

    public String getMd5() {
        return md5;
    }

    public void setMd5(String md5) {
        this.md5 = md5;
    }

    @Override
    public String getLogFormName() {
        if (StringUtils.isEmpty(super.logFormName)) {
            return "模板管理";
        } else {
            return super.logFormName;
        }
    }

    @Override
    public String getLogTitle() {
        if (StringUtils.isEmpty(super.logTitle)) {
            return "模板";
        } else {
            return super.logTitle;
        }
    }

}
